<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qvalidator.cpp -->
  <title>QDoubleValidator Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QDoubleValidator</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QDoubleValidator Class</h1>
<!-- $$$QDoubleValidator-brief -->
<p>The QDoubleValidator class provides range checking of floating-point numbers. <a href="#details">More...</a></p>
<!-- @@@QDoubleValidator -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QDoubleValidator&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qvalidator.html">QValidator</a></td></tr></table></div><ul>
<li><a href="qdoublevalidator-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#Notation-enum">Notation</a></b> { StandardNotation, ScientificNotation }</td></tr>
</table></div>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b> : double</li>
<li class="fn"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b> : int</li>
<li class="fn"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b> : Notation</li>
<li class="fn"><b><a href="qdoublevalidator.html#top-prop">top</a></b> : double</li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#QDoubleValidator-1">QDoubleValidator</a></b>(double <i>bottom</i>, double <i>top</i>, int <i>decimals</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#QDoubleValidator">QDoubleValidator</a></b>(QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#dtor.QDoubleValidator">~QDoubleValidator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDoubleValidator::Notation </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#bottom-prop">setBottom</a></b>(<i>double</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">setDecimals</a></b>(<i>int</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">setNotation</a></b>(<i>QDoubleValidator::Notation</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#setRange">setRange</a></b>(double <i>minimum</i>, double <i>maximum</i>, int <i>decimals</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#top-prop">setTop</a></b>(<i>double</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#top-prop">top</a></b>() const</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QValidator::State </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#validate">validate</a></b>(QString &amp;<i>input</i>, int &amp;<i>pos</i>) const override</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#bottom-prop">bottomChanged</a></b>(double <i>bottom</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">decimalsChanged</a></b>(int <i>decimals</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">notationChanged</a></b>(QDoubleValidator::Notation <i>notation</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#top-prop">topChanged</a></b>(double <i>top</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QDoubleValidator-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>QDoubleValidator provides an upper bound, a lower bound, and a limit on the number of digits after the decimal point. It does not provide a <a href="qvalidator.html#fixup">fixup</a>() function.</p>
<p>You can set the acceptable range in one call with <a href="qdoublevalidator.html#setRange">setRange</a>(), or with <a href="qdoublevalidator.html#bottom-prop">setBottom</a>() and <a href="qdoublevalidator.html#top-prop">setTop</a>(). Set the number of decimal places with <a href="qdoublevalidator.html#decimals-prop">setDecimals</a>(). The <a href="qdoublevalidator.html#validate">validate</a>() function returns the validation state.</p>
<p>QDoubleValidator uses its <a href="qvalidator.html#locale">locale</a>() to interpret the number. For example, in the German locale, &quot;1,234&quot; will be accepted as the fractional number 1.234. In Arabic locales, QDoubleValidator will accept Arabic digits.</p>
<p><b>Note: </b>The <a href="../qtcore/qlocale.html#NumberOption-enum">QLocale::NumberOptions</a> set on the <a href="qvalidator.html#locale">locale</a>() also affect the way the number is interpreted. For example, since <a href="../qtcore/qlocale.html#NumberOption-enum">QLocale::RejectGroupSeparator</a> is not set by default, the validator will accept group separators. It is thus recommended to use <a href="../qtcore/qlocale.html#toDouble">QLocale::toDouble</a>() to obtain the numeric value.</p></div>
<p><b>See also </b><a href="qintvalidator.html">QIntValidator</a>, <a href="qregexpvalidator.html">QRegExpValidator</a>, <a href="../qtcore/qlocale.html#toDouble">QLocale::toDouble</a>(), and <a href="../qtwidgets/qtwidgets-widgets-lineedits-example.html">Line Edits Example</a>.</p>
<!-- @@@QDoubleValidator -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Notation$$$StandardNotation$$$ScientificNotation -->
<h3 class="fn" id="Notation-enum"><a name="Notation-enum"></a>enum QDoubleValidator::<span class="name">Notation</span></h3>
<p>This enum defines the allowed notations for entering a double.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QDoubleValidator::StandardNotation</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The string is written as a standard number (i.e&#x2e; 0.015).</td></tr>
<tr><td class="topAlign"><code>QDoubleValidator::ScientificNotation</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The string is written in scientific form. It may have an exponent part(i.e&#x2e; 1.5E-2).</td></tr>
</table></div>
<p>This enum was introduced or modified in Qt 4.3.</p>
<!-- @@@Notation -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$bottom-prop$$$bottom$$$setBottomdouble$$$bottomChangeddouble -->
<h3 class="fn" id="bottom-prop"><a name="bottom-prop"></a><span class="name">bottom</span> : <span class="type">double</span></h3>
<p>This property holds the validator's minimum acceptable value</p>
<p>By default, this property contains a value of -infinity.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> double </td><td class="memItemRight bottomAlign"><span class="name"><b>bottom</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setBottom</b></span>(<i>double</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>bottomChanged</b></span>(double <i>bottom</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p>
<!-- @@@bottom -->
<!-- $$$decimals-prop$$$decimals$$$setDecimalsint$$$decimalsChangedint -->
<h3 class="fn" id="decimals-prop"><a name="decimals-prop"></a><span class="name">decimals</span> : <span class="type">int</span></h3>
<p>This property holds the validator's maximum number of digits after the decimal point</p>
<p>By default, this property contains a value of 1000.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>decimals</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDecimals</b></span>(<i>int</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>decimalsChanged</b></span>(int <i>decimals</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p>
<!-- @@@decimals -->
<!-- $$$notation-prop$$$notation$$$setNotationQDoubleValidator::Notation$$$notationChangedQDoubleValidator::Notation -->
<h3 class="fn" id="notation-prop"><a name="notation-prop"></a><span class="name">notation</span> : <span class="type"><a href="qdoublevalidator.html#Notation-enum">Notation</a></span></h3>
<p>This property holds the notation of how a string can describe a number</p>
<p>By default, this property is set to <a href="qdoublevalidator.html#Notation-enum">ScientificNotation</a>.</p>
<p>This property was introduced in Qt 4.3.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QDoubleValidator::Notation </td><td class="memItemRight bottomAlign"><span class="name"><b>notation</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setNotation</b></span>(<i>QDoubleValidator::Notation</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>notationChanged</b></span>(QDoubleValidator::Notation <i>notation</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qdoublevalidator.html#Notation-enum">Notation</a>.</p>
<!-- @@@notation -->
<!-- $$$top-prop$$$top$$$setTopdouble$$$topChangeddouble -->
<h3 class="fn" id="top-prop"><a name="top-prop"></a><span class="name">top</span> : <span class="type">double</span></h3>
<p>This property holds the validator's maximum acceptable value</p>
<p>By default, this property contains a value of infinity.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> double </td><td class="memItemRight bottomAlign"><span class="name"><b>top</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTop</b></span>(<i>double</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>topChanged</b></span>(double <i>top</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p>
<!-- @@@top -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QDoubleValidator$$$QDoubleValidatordoubledoubleintQObject* -->
<h3 class="fn" id="QDoubleValidator-1"><a name="QDoubleValidator-1"></a>QDoubleValidator::<span class="name">QDoubleValidator</span>(<span class="type">double</span> <i>bottom</i>, <span class="type">double</span> <i>top</i>, <span class="type">int</span> <i>decimals</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a validator object with a <i>parent</i> object. This validator will accept doubles from <i>bottom</i> to <i>top</i> inclusive, with up to <i>decimals</i> digits after the decimal point.</p>
<!-- @@@QDoubleValidator -->
<!-- $$$QDoubleValidator[overload1]$$$QDoubleValidatorQObject* -->
<h3 class="fn" id="QDoubleValidator"><a name="QDoubleValidator"></a>QDoubleValidator::<span class="name">QDoubleValidator</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a validator object with a <i>parent</i> object that accepts any double.</p>
<!-- @@@QDoubleValidator -->
<!-- $$$~QDoubleValidator[overload1]$$$~QDoubleValidator -->
<h3 class="fn" id="dtor.QDoubleValidator"><a name="dtor.QDoubleValidator"></a><code>[virtual] </code>QDoubleValidator::<span class="name">~QDoubleValidator</span>()</h3>
<p>Destroys the validator.</p>
<!-- @@@~QDoubleValidator -->
<!-- $$$setRange[overload1]$$$setRangedoubledoubleint -->
<h3 class="fn" id="setRange"><a name="setRange"></a><code>[virtual] </code><span class="type">void</span> QDoubleValidator::<span class="name">setRange</span>(<span class="type">double</span> <i>minimum</i>, <span class="type">double</span> <i>maximum</i>, <span class="type">int</span> <i>decimals</i> = 0)</h3>
<p>Sets the validator to accept doubles from <i>minimum</i> to <i>maximum</i> inclusive, with at most <i>decimals</i> digits after the decimal point.</p>
<!-- @@@setRange -->
<!-- $$$validate[overload1]$$$validateQString&int& -->
<h3 class="fn" id="validate"><a name="validate"></a><code>[override virtual] </code><span class="type"><a href="qvalidator.html#State-enum">QValidator::State</a></span> QDoubleValidator::<span class="name">validate</span>(<span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>input</i>, <span class="type">int</span> &amp;<i>pos</i>) const</h3>
<p>Reimplements: <a href="qvalidator.html#validate">QValidator::validate</a>(QString &amp;input, int &amp;pos) const.</p>
<p>Returns <a href="qvalidator.html#State-enum">Acceptable</a> if the string <i>input</i> contains a double that is within the valid range and is in the correct format.</p>
<p>Returns <a href="qvalidator.html#State-enum">Intermediate</a> if <i>input</i> contains a double that is outside the range or is in the wrong format; e.g&#x2e; is empty.</p>
<p>Returns <a href="qvalidator.html#State-enum">Invalid</a> if the <i>input</i> is not a double or with too many digits after the decimal point.</p>
<p>Note: If the valid range consists of just positive doubles (e.g&#x2e; 0.0 to 100.0) and <i>input</i> is a negative double then <a href="qvalidator.html#State-enum">Invalid</a> is returned. If <a href="qdoublevalidator.html#notation-prop">notation</a>() is set to <a href="qdoublevalidator.html#Notation-enum">StandardNotation</a>, and the input contains more digits before the decimal point than a double in the valid range may have, <a href="qvalidator.html#State-enum">Invalid</a> is returned. If <a href="qdoublevalidator.html#notation-prop">notation</a>() is <a href="qdoublevalidator.html#Notation-enum">ScientificNotation</a>, and the input is not in the valid range, <a href="qvalidator.html#State-enum">Intermediate</a> is returned. The value may yet become valid by changing the exponent.</p>
<p>By default, the <i>pos</i> parameter is not used by this validator.</p>
<!-- @@@validate -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
